package component.fulltextsearch.index.handlingtypes;

import java.io.PrintStream;
import java.io.PrintWriter;

/**
 * 文件转换异常
 *
 */
public class FileHandlerException extends Exception {

	private Throwable cause;

	public FileHandlerException() {
		super();
	}

	public FileHandlerException(String message) {
		super(message);
	}

	public FileHandlerException(Throwable cause) {
		super(cause.toString());
		this.cause = cause;
	}

	public FileHandlerException(String message, Throwable cause) {
		super(message, cause);
	}

	public Throwable getException() {
		return cause;
	}

	public void printStackTrace() {
		printStackTrace(System.err);
	}

	public void printStackTrace(PrintStream ps) {
		synchronized (ps) {
			super.printStackTrace(ps);
			if (cause != null) {
				ps.println("--- Nested Exception ---");
				cause.printStackTrace(ps);
			}
		}
	}

	public void printStackTrace(PrintWriter pw) {
		synchronized (pw) {
			super.printStackTrace(pw);
			if (cause != null) {
				pw.println("--- Nested Exception ---");
				cause.printStackTrace(pw);
			}
		}
	}
}
